home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / rtx2000.zip / rtx2000 / fctest next >
Text File  |  1993-09-01  |  10KB  |  451 lines

  1. ( This is a test file for the fc compiler which demonstrates code production and
  2. optimization -- it is not an actual running program )
  3.  
  4. ( Compare the .lst file obtained from compiling this file using the -l option 
  5. with this source file to see how code is produced )
  6.  
  7. (Throughout the file, commas are used to cause immeadate code production.
  8. This causes the compiler to stop looking for more instructions to combine into
  9. the machine code currently being produced. ) 
  10.  
  11. ( Note that there are several types of constants used 
  12.     a: short positive constants 0 to 31
  13.     b: short negative constants -32 to -1
  14.     c: long constants (all other sixteen bit numbers)
  15. )
  16.  
  17. : shift_test
  18. ( Each of 15 shift instructions )    
  19. 0< 
  20. 2* 
  21. 2*c 
  22. cU2/ 
  23. c2/ 
  24. U2/ 
  25. 2/ 
  26. N2* 
  27. N2*c 
  28. D2* 
  29. D2*c 
  30. cUD2/
  31. cD2/ 
  32. UD2/ 
  33. D2/
  34. nop
  35. ;
  36.  
  37.  
  38.  
  39. : alu_ops
  40. ( alu operations )
  41. and
  42. swap and
  43. swap -
  44. or 
  45. swap or
  46. swap +
  47. xor 
  48. swap xor
  49. nor 
  50. swap nor
  51. -c 
  52. swap -c
  53. nand
  54. swap nand
  55. +c
  56. swap +c
  57. xnor 
  58. swap xnor
  59. nop
  60. ;
  61.  
  62. : invert_shift_optional
  63. (following instructions can be combined together with a "not" and/or shift )
  64. (the shift and constants used are arbitrary )
  65.  
  66. drop dup                ( 16 bits )         
  67. drop dup 2* 
  68. drop dup not 
  69. drop dup not 2*               
  70. swap drop               ( 16 bits )                             
  71. swap drop 2* 
  72. swap drop not 
  73. swap drop not 2* 
  74. drop                    ( 16 bits )
  75. drop 2*  
  76. drop not 
  77. drop  not 2* 
  78. swap drop dup           ( 16 bits )
  79. swap drop dup 2* 
  80. swap drop dup not 
  81. swap drop dup not 2*  
  82. swap ,                    ( 16 bits )
  83. swap 2* 
  84. swap not 
  85. swap not 2* 
  86. dup                     ( 16 bits )
  87. dup 2* 
  88. dup not 
  89. dup not 2* 
  90. over ,                    ( 16 bits )
  91. over 2* 
  92. over not 
  93. over not 2* 
  94. over over               ( 32 bits )
  95. over over 2* 
  96. over over not 
  97. over over not 2*  
  98. over swap              ( 32 bits )
  99. over swap 2*
  100. over swap not 
  101. over swap not 2* 
  102. swap over               ( 32 bits )
  103. swap over 2* 
  104. swap over not 
  105. swap over not 2* 
  106. 0x15 g@ over            ( 32 bits )
  107. 0x15 g@ over 2* 
  108. 0x15 g@ over not 
  109. 0x15 g@ over not 2* 
  110. 0x15 over               ( 32 bits )
  111. 0x15 over 2* 
  112. 0x15 over not 
  113. 0x15 over not 2*  
  114. 0x15 swap               ( 32 bits )
  115. 0x15 swap 2* 
  116. 0x15 swap not 
  117. 0x15 swap not 2*  
  118. -1 swap                 ( 32 bits )
  119. -1 swap 2* 
  120. -1 swap not 
  121. -1 swap not 2* 
  122. 0x15 u@ over           ( 32 bits )
  123. 0x15 u@ over 2* 
  124. 0x15 u@ over not 
  125. 0x15 u@ over not 2*  
  126. @ over                  ( 32 bits )
  127. @ over 2* 
  128. @ over not 
  129. @ over not 2* 
  130. c@ over                 ( 32 bits )
  131. c@ over 2*
  132. c@ over not
  133. c@ over not 2*
  134. 0x5555 over             ( 48 bits )
  135. 0x5555 over 2* 
  136. 0x5555 over not 
  137. 0x5555 over not 2* 
  138. nop
  139. ;
  140.  
  141. : shift_optional
  142. (these instructions can be combined with a shift )
  143. (the shift and alu op are arbitrary )
  144. over over -           ( 16 bits )
  145. over over - 2/ 
  146. over -                ( 16 bits )
  147. over - 2/
  148. -                     ( 16 bits )
  149. - 2/
  150. swap over -           ( 16 bits )
  151. swap over - 2/ 
  152. not                   ( 16 bits )
  153. not 2/    
  154. nop
  155. ;
  156.  
  157. : invert_optional
  158. (these instuctions can be combined with a "not" )
  159. (constants are arbitrary )
  160. 0x15                   ( 16 bits - short positive constant )
  161. 0x15 not
  162. -10                   ( 16 bits - short negative constant )
  163. -10 not
  164. 0x15 swap drop        ( 16 bits )
  165. 0x15 swap drop not  
  166. -10 swap drop         ( 16 bits )
  167. -10 swap drop not
  168. drop 0x15             ( 16 bits )
  169. drop 0x15 not 
  170. drop -10              ( 16 bits )
  171. drop -10 not          
  172. dup 0x15              ( 32 bits )
  173. dup 0x15 not 
  174. 0x15 u@ swap          ( 16 bits )
  175. 0x15 u@ swap not  
  176. 0x15 u@               ( 16 bits )
  177. 0x15 u@ not
  178. dup 0x15 u@           ( 32 bits )
  179. dup 0x15 u@ not 
  180. dup 0x15 u!           ( 16 bits )
  181. dup 0x15 u! not     
  182. 0x15 u!               ( 16 bits )
  183. 0x15 u! not         
  184. @ swap                ( 16 bits )
  185. @ swap not      
  186. c@ swap               ( 16 bits )
  187. c@ swap not
  188. @                     ( 16 bits )
  189. @ not              
  190. c@                    ( 16 bits )
  191. c@ not
  192. dup @                 ( 32 bits )
  193. dup @ not
  194. dup c@                ( 32 bits )
  195. dup c@ not      
  196. dup @ swap 0x15       ( 32 bits )
  197. dup @ swap 0x15 not 
  198. dup c@ swap 0x15      ( 32 bits )
  199. dup c@ swap 0x15 not   
  200. swap drop @           ( 32 bits )
  201. swap drop @ not
  202. swap drop c@          ( 32 bits )
  203. swap drop c@ not       
  204. swap drop dup @ ,      ( 32 bits )
  205. swap drop dup @ not
  206. swap drop dup c@ ,      ( 32 bits )
  207. swap drop dup c@ not   
  208. swap drop dup @ swap 0x15      ( 32 bits )
  209. swap drop dup @ swap 0x15 not 
  210. swap drop dup c@ swap 0x15     ( 32 bits )
  211. swap drop dup c@ swap 0x15 not
  212. over swap !                    ( 16 bits )
  213. over swap ! not              
  214. over swap c!                   ( 16 bits )
  215. over swap c! not           
  216. swap over ! 0x15               ( 32 bits )
  217. swap over ! 0x15 not     
  218. swap over c! 0x15              ( 32 bits )
  219. swap over c! 0x15 not  
  220. over over ! 0x15               ( 32 bits )
  221. over over ! 0x15 not     
  222. over over c! 0x15              ( 32 bits )
  223. over over c! 0x15 not        
  224. !                               ( 16 bits )
  225. ! not
  226. c!                              ( 16 bits )
  227. c! not                    
  228. nop
  229. ;
  230.  
  231. : terminal    
  232. (these instructions can not be combined with any more instructions )
  233. 0x15 over -         ( 16 bits )
  234. dup 0x15 -          ( 16 bits )
  235. 0x15 -              ( 16 bits )
  236. 0x15 u@ over -      ( 16 bits )
  237. dup 0x15 u@ -       ( 16 bits )
  238. 0x15 u@ -           ( 16 bits )
  239. @ over -            ( 16 bits )
  240. c@ over -           ( 16 bits )
  241. dup @ swap          ( 16 bits )
  242. dup c@ swap ,        ( 16 bits )
  243. swap drop dup @ swap ,  ( 16 bits )
  244. swap drop dup c@ swap   ( 16 bits )
  245. @ 0x15                 ( 16 bits )
  246. c@ 0x15                ( 16 bits )
  247. swap drop @ 0x15       ( 16 bits )
  248. swap drop c@ 0x15      ( 16 bits )
  249. dup @ swap 0x15 -      ( 16 bits )
  250. dup c@ swap 0x15 -      ( 16 bits )
  251. swap drop dup @ swap 0x15 -   ( 16 bits )
  252. swap drop dup c@ swap 0x15 -  ( 16 bits )
  253. @+                         ( 16 bits )
  254. c@+                        ( 16 bits )
  255. @-                         ( 16 bits )
  256. c@-                        ( 16 bits )
  257. swap drop @+               ( 16 bits )
  258. swap drop c@+              ( 16 bits )
  259. swap drop @-               ( 16 bits )
  260. swap drop c@-              ( 16 bits )
  261. @ -                        ( 16 bits )
  262. c@ -                       ( 16 bits )
  263. swap over !                ( 16 bits )
  264. swap over c!               ( 16 bits )
  265. over over !                ( 16 bits )
  266. over over c!               ( 16 bits )
  267. ! 0x15                     ( 16 bits )
  268. c! 0x15                    ( 16 bits )
  269. over swap ! 0x15           ( 16 bits )
  270. over swap c! 0x15          ( 16 bits )
  271. !+                         ( 16 bits )
  272. c!+                        ( 16 bits )
  273. !-                         ( 16 bits )
  274. c!-                        ( 16 bits )
  275. over swap !+               ( 16 bits )
  276. over swap c!+              ( 16 bits )
  277. over swap !-               ( 16 bits )
  278. over swap c!-              ( 16 bits )
  279. swap over ! 0x15 -         ( 16 bits )
  280. swap over c! 0x15 -        ( 16 bits )
  281. over over ! 0x15 -         ( 16 bits )
  282. over over c! 0x15 -        ( 16 bits )
  283. nop
  284. ;
  285.  
  286. : g_types
  287. ( these instructions allow access of the ASIC bus )    
  288. 0x15 g@ drop                 ( 16 bits )
  289. 0x15 g@ drop not
  290. 0x15 g@                      ( 16 bits )
  291. 0x15 g@ not 
  292. dup 0x15 g@                  ( 32 bits )
  293. dup 0x15 g@ not 
  294. dup 0x15 g!                  ( 16 bits )
  295. dup 0x15 g! not 
  296. 0x15 g!                      ( 16 bits )
  297. 0x15 g! not 
  298. 0x15 g@ over -               ( 16 bits )
  299. dup 0x15 g@ -                ( 16 bits )
  300. 0x15 g@ -                    ( 16 bits )
  301. nop
  302. ;
  303.  
  304. : long_constants
  305. (these are instructions for loading long constants onto the stack )
  306. 0x5555 swap                   ( 32 bits )
  307. 0x5555 swap not 
  308. 0x5555                        ( 32 bits )
  309. 0x5555 not
  310. 0x5555 swap drop              ( 32 bits )
  311. 0x5555 swap drop not
  312. drop 0x5555                   ( 32 bits )
  313. drop 0x5555 not 
  314. dup 0x5555                    ( 48 bits )
  315. dup 0x5555 not   
  316. 0x5555 -                      ( 32 bits )
  317. dup 0x5555 -                  ( 32 bits )
  318. 0x5555 over -                 ( 32 bits )
  319. (Strings )
  320. "test"                        ( varies with length of string ) 
  321. "test" not                   
  322. (Tick)
  323. ['] alu_ops                 ( 32 bits )
  324. ['] alu_ops not 
  325. ['] test4                       ( 32 bits )
  326. ['] test4 not
  327. nop 
  328. ;
  329.  
  330. (Return coding)
  331. : test2 exit exit exit ;
  332. : test3 not ;
  333. : test4 1 ;
  334. : test5 0 g@ exit 1 g@ exit 2 g@ ;
  335. : test6 0 g! exit 1 g! exit 2 g! ;
  336. : test7 3 g@ exit 3 g! exit 4 g@ ;
  337. : test8 0x5555 exit 0x5555 ;
  338.  
  339. (swaps)
  340. : test9 swap swap swap swap swap ;
  341.  
  342. (0x3f0 code ( if nexting ))
  343. : test10
  344. if 
  345.     if
  346.         if 
  347.             if 
  348.                 if 
  349.                     if 
  350.                         if
  351.                             if 
  352.                                 if nop else 
  353.                                 nop then 
  354.                             else nop 
  355.                             then if nop then 
  356.                         then
  357.                     then 
  358.                 then
  359.             then 
  360.         then 
  361.     then
  362. then ;
  363.  
  364. (0x3f0 code (for next nesting))
  365. : test12
  366. for 
  367.     for 
  368.         for
  369.             for
  370.                 for 
  371.                     for
  372.                         for
  373.                             for
  374.                                 for
  375.                                     nop
  376.                                 next
  377.                             next
  378.                         next
  379.                     next
  380.                 next
  381.             next
  382.         next
  383.     next
  384. next ;
  385.  
  386. ( Note with word tables any undefined labels are assummed to be words )
  387.  
  388. word table1 { test2 test3 test4  0 1 2 3 -1 -2 -3 test11 }
  389.  
  390. byte table2 { 1 2 3 4 5 6 7 }
  391.  
  392. word table3 { table1 table2 table3 }
  393.  
  394. : test11
  395. ( demo of looping features )
  396. begin
  397.    begin
  398.      begin
  399.        begin
  400.          begin
  401.            begin
  402.              begin
  403.              again
  404.            again
  405.          again
  406.        again
  407.      again
  408.    again
  409. again
  410.  
  411. begin
  412.    begin
  413.      begin
  414.        begin
  415.          begin
  416.            begin
  417.              begin
  418.              until
  419.            until
  420.          until
  421.        until
  422.      until
  423.    until
  424. until
  425.  
  426. begin
  427.    begin
  428.      begin
  429.        begin
  430.          begin
  431.            begin
  432.              begin
  433.               while
  434.              repeat
  435.            while
  436.            repeat
  437.          while
  438.          repeat
  439.        while
  440.        repeat
  441.      while
  442.      repeat
  443.    while
  444.    repeat
  445. while
  446. repeat
  447. nop
  448. ;
  449.